package com.zxy.supplier_system.server.repository

import com.zxy.supplier_system.server.entity.MobileAppVersion
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface MobileAppVersionRepository : JpaRepository<MobileAppVersion, String> {


    @Query("""from MobileAppVersion mobileAppVersion
         where mobileAppVersion.version.majorVersion > :#{#version.majorVersion}
          or( mobileAppVersion.version.majorVersion=:#{#version.majorVersion} and mobileAppVersion.version.minorVersion > :#{#version.minorVersion})
          or (mobileAppVersion.version.majorVersion=:#{#version.majorVersion} and mobileAppVersion.version.minorVersion=:#{#version.minorVersion} and mobileAppVersion.version.patchVersion > :#{#version.patchVersion})
        order by mobileAppVersion.version.majorVersion desc ,mobileAppVersion.version.minorVersion desc ,mobileAppVersion.version.patchVersion desc""")
    fun findLatestVersionsAfter(version: MobileAppVersion.Version): List<MobileAppVersion>

}